package 优先算法.滑动窗口.无重复字符的最长子串;

import java.util.HashSet;
import java.util.Set;

public class teacher {

}
class Solution2 {
    public int lengthOfLongestSubstring(String ss) {
        char[] s = ss.toCharArray();

        int[] hash = new int[128];
        int left=0 , right=0,len=0,n=ss.length();
        while(right<n){
            hash[s[right]]++;//进窗口
            while(hash[s[right]]>1){//出窗口
                hash[s[left++]]--;
            }
            len=Math.max(len,right-left + 1);//加的是left刚刚++的1
            right++;
        }
        return len;
    }
}